<%@ page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" import="java.util.*" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>巡检预约 - 创建</title>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
 </head>
 <body>
	<t:formvalid formid="formobj" dialog="false" usePlugin="password" layout="table" action="cbsInspectionAppointmentController.do?doApprovalSubmit" tiptype="3" callback="subCallBack">
	<input type="hidden" name="taskId" value="${task.id }">
	<input type="hidden" name="instId" value="${instId }">
	<input type="hidden" name="busId" value="${bus.id }">
	<input type="hidden" name="status" id="status">
		<div class="subtitle">
			<p>客户信息</p>
			<table class="nobordertable noborder">
                <c:if test="${not empty inAppId}">
                    <tr>
                        <td class="al_r">
                            <label>巡检预约服务ID:</label>
                        </td>
                        <td>
                                ${inAppId}
                        </td>
                        <td class="al_r"></td>
                        <td></td>
                    </tr>
                </c:if>
				<tr>
					<td class="al_r" width="20%">
						<label>影院名称:</label>
					</td>
					<td  width="30%">${bus.cinema.name }</td>
                    <td class="al_r">
                        <label>联系人姓名:</label>
                    </td>
                    <td>${bus.contactName }</td>

				</tr>
				<tr>

					<td class="al_r">
						<label>电话:</label>
					</td>
					<td>${bus.phone }</td>
                    <td class="al_r">
                        <label>邮箱：</label>
                    </td>
                    <td>${bus.mail }</td>
				</tr>
				<tr>
					<td class="al_r">
						<label>期望巡检季度:</label>
					</td>
					<td>
                        <fmt:formatDate value="${bus.expectDate}" type="date" pattern="yyyy"/>年
                            <t:dictSelect field="expectSection" type="span" typeGroupCode="<%=StaticValue.DIC_APPOINT_EXPECT_SECTION%>" defaultVal="${bus.expectSection}"></t:dictSelect>
					</td>
                    <td class="al_r" width="20%"></td>
                    <td width="30%"></td>
				</tr>
				<tr>
					<td class="al_r">
						<label>说明：</label>
					</td>
					<td colspan="3">
                        <textarea rows="3" style="width: 90%;border: none">${bus.content}</textarea>
                    </td>
				</tr>
			</table>
		</div>
		
		<div class="subtitle" >
			<p>相关设备</p>
		</div>
		  <table style="line-height: 35px;" cellpadding="0" cellspacing="1" class="formtable" id="equipmentTab">
		     <tr align="center">
		       <td>设备SN</td>
		       <td>型号</td>
		       <td>机型</td>
		       <td>发货日期</td>
		       <td>安装日期</td>
		       <td>保期截至日期</td>
		       <td>状态</td>
		     </tr>
		     <c:forEach items="${bus.esList }" var='es'>
				<tr align="center" style="background-color: #FFFFFF;">
					<td>${es.es.sn }</td>
					<td>${es.es.item }</td>
					<td>${es.es.type.typeDesc }</td>
					<td><fmt:formatDate value="${es.es.sendDate }" pattern="yyyy-MM-dd"/></td>
					<td><fmt:formatDate value="${es.es.installDate }" pattern="yyyy-MM-dd"/></td>
					<td><fmt:formatDate value="${es.es.repairEndDate }" pattern="yyyy-MM-dd"/></td>
					<td>
						<c:if test="${es.type eq '0'}">无巡检计划</c:if>
						<c:if test="${es.type eq '1'}">有巡检计划</c:if>
						<c:if test="${es.type eq '2'}">本年度已巡检</c:if>
					</td>
				</tr>		     
		     </c:forEach>
		  </table>
		  
		<c:if test="${fn:length(recordList) > 0 }">
			<div class="subtitle" >
				<p>审批记录</p> &nbsp;
			</div>
			  <table style="line-height: 35px;" cellpadding="0" cellspacing="1" class="formtable" >
			     <tr align="center">
			       <td>操作人</td>
			       <td>操作时间</td>
			       <td  width="70%">操作内容</td>
			     </tr>
			     
			     <c:forEach items="${recordList }" var='record'>
					<tr align="center" style="background-color: #FFFFFF;">
						<td>${record.tsUser.realName }</td>
						<td><fmt:formatDate value="${record.createDate }" pattern="yyyy-MM-dd HH:mm"/></td>
						<td>${record.remark }</td>
					</tr>
			     </c:forEach>
			  </table>
		</c:if>
	</t:formvalid>
	<c:if test="${empty isDetail}">
		<div style="text-align: center;margin: 50px;">
			<c:if test="${task.taskDefinitionKey eq 'taskNode1' }">
                <c:if test="${hasHd eq true}">
                    <a class="easyui-linkbutton" onclick="transferredWin()">转派</a>   &nbsp;&nbsp;&nbsp;&nbsp;
                </c:if>
				<a class="easyui-linkbutton" onclick="needReject()">取消</a>
			</c:if>
			<c:if test="${task.taskDefinitionKey eq 'taskNode2' }">
				<a class="easyui-linkbutton" onclick="save(0)">同意</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="easyui-linkbutton" onclick="disagree(1)">不同意</a>
			</c:if>
            <c:if test="${task.taskDefinitionKey eq 'taskNode3' }">
                <a class="easyui-linkbutton" onclick="save()">提交审批</a>    &nbsp;&nbsp;&nbsp;&nbsp;
                <a class="easyui-linkbutton" onclick="needReject()">取消</a>
            </c:if>
		</div>
	</c:if>
 </body>
<script type="text/javascript">

function save(status){
	if(status != undefined){
		$('#status').val(status);
	}
	$('#formobj').submit();
}

function disagree(status){
	var url = "cbsProcurementNoteController.do?goRejectPage&url=cbsInspectionAppointmentController.do?doApprovalSubmit-taskId=${task.id }-busId=${bus.id}-instId=${instId}-status="+status;
	openRejectWin(url);
}

function needReject(){
	var url = "cbsProcurementNoteController.do?goRejectPage&url=cbsInspectionAppointmentController.do?closeFlow-taskId=${task.id }-busId=${bus.id}-instId=${instId}";
	openRejectWin(url);
}

function openRejectWin(url){
	W.$.dialog({
		content: 'url:'+url,
		lock : true,
		width:500,
		//zIndex:1990,
		height:200,
		parent:windowapi,
		title:'原因',
		opacity : 0.3,
		cache:false,
	    ok: function(){
	    	iframe = this.iframe.contentWindow;
	    	iframe.$('#formobj').submit();
			return false;
	    },
	    cancelVal: '关闭',
	    cancel: true /*为true等价于function(){}*/
	}).zindex();
}

function subCallBack(data){
	top.tip(data.msg);
	if('${bus.id }' !=""){
		//刷新列表
		loadDatagrid();
	}else{
		closeCurrentTab();
	}
	
}

function loadDatagrid(){
	var win = frameElement.api.opener;
	win.reloadTable();
	frameElement.api.close();
}
//取消流程
function cancelFlow(){
	$.post('cbsInspectionAppointmentController.do?closeFlow',{instId:'${instId}',taskId:'${task.id}',busId:'${bus.id}'},function(data){
		data = $.parseJSON(data);
		top.tip(data.msg);
		loadDatagrid();	
	})
}
function transferredWin(){
	var taskId = '';
	var url = "cbsProcurementNoteController.do?goNodeTransferred&taskId=${task.id }&busId=${bus.id}&instId=${instId}&type=appoint";
	W.$.dialog({
		content: 'url:'+url,
		lock : true,
		width:500,
		//zIndex:1990,
		height:220,
		parent:windowapi,
		title:"填写转派信息",
		opacity : 0.3,
		cache:false
	}).zindex();
}
</script>